#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int n, m;
	int arr[10][10];
	while (scanf("%d%d", &n, &m) == 2)
	{
		int i, j;
		for (i = 0; i < n; i++) 
		{
			for (j = 0; j < m; j++) 
			{
				scanf("%d", &arr[i][j]);        //1 2 3
			}                                   //2 3 4
		}
		for (i = 0; i < m; i++) //m=3
		{
			for (j = 0; j < n; j++) //n=2
			{
				printf("%d ", arr[j][i]); 
			}
			printf("\n");
		}

	}

	return 0;
}